#include <iostream>
using namespace std;

/*
	体会面向对象的编程：
	    解决问题的时候：
		    分析该问题涉及到哪些对象--》封装对应的类--》(方法和属性)
			类创建对象--》对象调用方法解决问题
*/
class Book
{
public:
	Book()
	{
		
	}
	Book(string _name,string _num,string _author)
	{
		name=_name;
		num=_num;
		author=_author;
	}
	void dispBook()
	{
		cout<<"书名: "<<name<<"  作者: "<<author<<endl;
		
	}
private:
	string name;
	string num;
	string author;
};

class Reader
{
public:
	Reader(string _name,string _id)
	{
		name=_name;
		id=_id;
		i=0; //记录数组下标
	}
	//借书
	void borrowBook(Book &b)
	{
		if(i<=4)
		{
			array[i]=b;
			i++;
		}
		else
		{
			cout<<"您借书额度满了"<<endl;
		}	
	}
	
	//打印借书信息
	void disp()
	{
		int j;
		cout<<name<<",读者证编号: "<<id<<",目前借书的情况如下:"<<endl;
		for(j=0; j<i; j++)
		{
			array[j].dispBook();
		}
	}
private:
	string name;
	string id;
	//一个读者最多借5本书,对象数组(结构体可以定义数组，为什么类不可以定义数组呢？)
	Book array[5]; //调用无参构造
	int i;
};

int main()
{
	//定义读者
	Reader r1("张三","gec123456");
	
	//定义六本书
	Book b1("西游记","001","吴承恩");
	Book b2("红楼梦","002","吴承恩");
	Book b3("水浒传","003","吴承恩");
	Book b4("三国演义","004","吴承恩");
	Book b5("小时代","005","吴承恩");
	Book b6("摆脱精神内耗","006","吴承恩");
	
	r1.borrowBook(b1);
	r1.borrowBook(b2);
	r1.borrowBook(b3);
	r1.borrowBook(b4);
	r1.borrowBook(b5);
	r1.borrowBook(b6);
	
	r1.disp();
}